critical css

39

"above the fold" is html you see on load, like the header
header > h1 { /* !Critical */ margin: 300px; }//annotated with a comment in main.css
npm install -g postcss-split main.css insert result main-critical.css in <head><style> 
<script id="load"> (https://github.com/filamentgroup/loadCSS)("main-critical.css", document.getElementById("load"));
<script> function insertLink(_url, _media) { 
 var link = document.createElement('link'); l.rel = 'stylesheet'; l.type = 'text/css'; l.href = _url; l.media = _media;
 document.getElementsByTagName('head')[0].appendChild(link)}
function dCss() { insertLink('url', 'all') }
if (window.addEventListener) {window.addEventListener(
  'DOMContentLoaded', dCss, false)} else { window.onload=dCss

Comments

Submit
0 Comments